package com.catchu.pattern.creational.迭代器模式.d双向迭代器;

import com.catchu.pattern.creational.迭代器模式.d双向迭代器.aggregate.ListPayAggregate;
import com.catchu.pattern.creational.迭代器模式.d双向迭代器.iterator.Iterator;

public class Client {

    public static void main(String[] args) {
        ListPayAggregate aggregate = new ListPayAggregate();
        aggregate.calcPay();

        Iterator iterator = aggregate.createIterator();

        iterator.first();
        if(!iterator.isDone()){
            Object obj = iterator.currentItem();
            System.out.println("第一个："+obj);
            iterator.next();
        }

        if(!iterator.isDone()){
            Object obj = iterator.currentItem();
            System.out.println("第二个："+obj);
            iterator.next();
        }

        if(!iterator.isFirst()){
            iterator.previous();
            Object obj = iterator.currentItem();
            System.out.println("第三个："+obj);
        }
    }
}
